#include <stdio.h>
#include "parse_options.h"

struct {
    int opt_integer;
    int opt_bool;
    char *opt_string;
}main_options;

struct option option_main_options[] = {
    {opt_t_int, "integer", 'i', opt_f_optarg, "get a integer", &main_options.opt_integer, 11},
    {opt_t_bool, "bool", 'b', opt_f_noarg, "get a boolean", &main_options.opt_bool, 0},
    {opt_t_string, "string", 's', opt_f_optarg, "get a string", &main_options.opt_string, 0},
    {opt_t_end, "long_name", '\0', opt_f_noarg, "end of option", NULL, 0}
};

char *option_help[] = {
	"parse_options demo, program [options] ...",
	NULL
};
int main(int argc, char **argv)
{
    int ret;
    if(ret=parse_options(argc, argv, option_main_options,option_help, parse_f_need_option)) {
        fprintf(stderr, "parse_options error, return %d.\n",ret);
        exit(129);
    }
	
    printf("opt_integer=%d\nopt_bool=%d\nopt_string=%s",
            main_options.opt_integer, 
            main_options.opt_bool,
            main_options.opt_string);

    return 0;
}

